import { request } from "@/http/axios"

// 获取产品列表
export function searchProduct(data) {
  return request({
    url: "products/search",
    method: "get",
    params: data
  })
}

// 查询产品
export function getProductList(data) {
  return request({
    url: "products",
    method: "get",
    data
  })
}

// 新增单个产品
export function addProduct(data) {
  return request({
    url: "products",
    method: "post",
    data
  })
}

// 
export function deleteProduct(id) {
  return request({
    url: `products/${id}`,
    method: "delete",
  })
}

// 修改单个产品
export function updateProduct(data) {
  return request({
    url: `products/${data.id}`,
    method: "put",
    data: {
      ...data,
      id: undefined
    },
  })
}

// 批量删除产品
export function batchDeleteProduct(data) {
  return request({
    url: "products/batch",
    method: "delete",
    data
  })
}
